package org.base.common.util;

import org.base.common.holder.TimeZoneOffsetHolder;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class I18nUtils {

    public static LocalDateTime i18nLocalDate(LocalDate localDate) {
        if (localDate != null) {
            final Integer offset = TimeZoneOffsetHolder.getOffset();
            if (offset != null && offset > 0) {
                return localDate.atStartOfDay().minus(offset, ChronoUnit.HOURS);
            }
            return localDate.atStartOfDay();
        }
        return null;
    }
}
